using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class SaberController : PlayerController
{
    public override void Awake()
    {
        base.Awake();
        GameManager.Instance.saber = this.gameObject;
        
    }

    public void Skill1Event()
    {
        var weapon = GameManager.Instance.playerStats.gameObject.transform.Find("root").GetChild(1)
            .GetChild(0);
        var currentInstance = Instantiate(SkillManager.Instance.SkillListSaber.items[0].skillEffect,weapon); 
        var psUpdater = currentInstance.GetComponent<PSMeshRendererUpdater>();
        psUpdater.UpdateMeshEffect(weapon.gameObject);
        BuffManager.Instance.SetDamageBuff(10.0f,6f,currentInstance);
        SkillManager.Instance.HaveCD[0] = true;
    }

    public void PrepareForSkill2Event()
    {
        RaycastHit hitInfo;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        Physics.Raycast(ray, out hitInfo);
        GameManager.Instance.playerStats.transform.DOLookAt(hitInfo.point,1);
        GameManager.Instance.playerStats.gameObject.transform.DOMove(hitInfo.point, 1);
        SkillManager.Instance.HaveCD[1] = true;
    }

    public void Skill2Event()
    {
        GameObject effect = SkillManager.Instance.SkillListSaber.items[1].skillEffect;
        var newEffect=Instantiate(effect, GameManager.Instance.playerStats.transform.position, Quaternion.identity);
        Destroy(newEffect,3f);
        SkillManager.Instance.CalucateDamage(transform.position,(int)(GameManager.Instance.playerStats.attackData.maxDamage*1.5f),SkillManager.Instance.SkillListSaber.items[1].AoeRange);
    }

    public void PrepareForeSkill3Event()
    {
        SkillManager.Instance.CalucateDamage(transform.position,SkillManager.Instance.SkillListSaber.items[2].damage,SkillManager.Instance.SkillListSaber.items[2].AoeRange);
        SkillManager.Instance.HaveCD[2] = true;
    }


    public void Skill3Event()
    {
        SkillManager.Instance.newEffect = Instantiate(SkillManager.Instance.SkillListSaber.items[2].skillParticle,
                    GameManager.Instance.playerStats.gameObject.transform.position, Quaternion.Euler(-90,0,0));
        
        SkillManager.Instance.CalucateDamage(transform.position,(int)(GameManager.Instance.playerStats.attackData.maxDamage*1.5f),SkillManager.Instance.SkillListSaber.items[2].AoeRange);
    }
    
}
